package com.javasm.mb_store_api_final.sys_control.logcontrol.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javasm.mb_store_api_final.sys_control.logcontrol.entity.SysLoginLog;
import com.javasm.mb_store_api_final.sys_control.logcontrol.entity.SysLogInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 系统访问记录(SysLoginLog)表数据库访问层
 *
 * @author makejava
 * @since 2024-08-04 16:45:04
 */
public interface SysLoginLogDao extends BaseMapper<SysLoginLog> {

    @Select("select * from sys_login_log")
    List<SysLoginLog> queryAllLog();

    @Select("<script>"
            + "SELECT * FROM sys_login_log log "
            + "<if test='deptName != null'>"
            + "WHERE log.dept_name = #{sysLogInfo.deptName} "
            + "</if>"
            + "<if test='title != null'>"
            + "AND log.title = #{sysLogInfo.title} "
            + "</if>"
            + "<if test='operIp != null'>"
            + "AND log.oper_ip = #{sysLogInfo.operIp} "
            + "</if>"
            + "<if test='operName != null'>"
            + "AND log.oper_name = #{sysLogInfo.operName} "
            + "</if>"
            + "<if test='username != null'>"
            + "AND log.username LIKE CONCAT('%', #{sysLogInfo.username}, '%') "
            + "</if>"
            + "</script>")
    List<SysLoginLog> queryBy(@Param("sysLogInfo")SysLogInfo sysLogInfo);
}